package com.kaifamiao.map;

import java.io.IOException;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.Properties;

/**
 * 1、Properties 表示 属性集
 * 2、属性集中存放的是 "属性名-属性值" 对 ( 本质上就是键值对 )
 * 3、设置属性:
 *      Object setProperty( String key, String value )
 * 4、获取属性值:
 *      String getProperty( String key )
 *      String getProperty( String key, String defaultValue )
 */
public class PropertiesTest1 {

    public static void main(String[] args) throws IOException {

        // Map<Object,Object> map = new Properties();
        // Hashtable<Object,Object> map = new Properties();
        Properties props = new Properties();

        Object value = props.setProperty( "name" , "李某芳" );
        System.out.println( value );

        System.out.println( props.setProperty( "name", "李芳" ) );
        System.out.println( props );

        String propertyValue = props.getProperty( "name" );
        System.out.println( propertyValue );

        propertyValue = props.getProperty( "age" , "18" );
        System.out.println( propertyValue );

        props.setProperty( "age", "19" );

        propertyValue = props.getProperty( "age" , "18" );
        System.out.println( propertyValue );

        // Writer writer = new PrintWriter( "info.properties" );
        Writer writer = new PrintWriter( "D:/info.properties" );
        props.store( writer, "" );


    }

}
